function [B] = Coalesce(A)
B = A;
deg = sum(A);

for i=max(size(deg)):-1:1
    if deg(i) == 1
        B(i,:) = zeros(1,max(size(deg)));
        B(:,i) = zeros(max(size(deg)),1);
    end
end

deg = sum(B);
for i=max(size(deg)):-1:1
    if deg(i) == 2
        for j=1:max(size(deg))
            if B(i,j) == 1
                for k=j+1:max(size(deg))
                    if B(i,k) == 1
                        B(j,k) = 1;
                        B(k,j) = 1;
                    end
                end
            end
        end     
        B(i,:) = zeros(1,max(size(deg)));
        B(:,i) = zeros(max(size(deg)),1);
    end
end

%Draw(B);
